<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Insert title here</title>
	<link rel="stylesheet" href="../../../../layui/css/layui.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="../../../css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" media="screen" href="../../../css/dataTables.bootstrap.min.css">
	<link rel="stylesheet" href="../../../../css/global.css">
	<link rel="stylesheet" href="../../../../css/mytable.css">
	<link rel="stylesheet" href="../../../../js/bigimg/bigimg.css"/>
	<link rel="stylesheet" href="" id='bugcss'>
		<script type="text/javascript">
			document.querySelector('#bugcss').href = '../../layuiadmin/style/bug.css?v=1.0&code=' + new Date();
		</script>
</head>
<body>
<div class="warp">
	<div class="layui-container form-main">
		<!--<div class="layui-row main-handle">
            <button onclick="location.href='husbandry_add.html'" class="layui-btn my-btn-blue my-min-width">添加产品批次</button>
            <button onclick="location.href='husbandry_assign.html'" class="layui-btn my-btn-blue my-min-width">指派农事任务</button>
            <button onclick="location.href='product_batche/product_batche_list.html'" class="layui-btn my-btn-blue my-min-width">农事审核</button>
        </div>-->
		<div class="layui-row main-title">
			农事活动审核
		</div>
		<div>
			<div class="widget-body no-padding">
				<table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
					<thead>
					<tr>
					</tr>
					<tr>
						<th>序号</th>
						<th>生产人员</th>
						<th>任务</th>
						<th>活动描述</th>
						<th>完成时间</th>
						<th>状态</th>
						<th>活动照片1</th>
						<th>活动照片2</th>
						<th>活动照片3</th>
						<th>留言</th>
						<th>操作</th>
					</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
		</div>
		<div class="main-operation">
			<button onclick="location.href='husbandry_list.html'" class="layui-btn layui-btn my-min-width">返回</button>
		</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript" src="../../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../../js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../../js/jq.js"></script>
<script type="text/javascript" src="../../../js/my/permission.js"></script>
<script type="text/javascript" src="../../../layui/layui.js"></script>
<script type="text/javascript" src="../../../js/dict.js"></script>
<script type="text/javascript" src="../../../js/common.js"></script>
<script type="text/javascript" src="../../../js/bigimg/bigimg.js"></script>
<script type="text/javascript" src="../../../js/mytable.js"></script>
<script type="text/javascript">
    layui.use([ 'layer' ], function() {
        var layer = layui.layer;
    });
    $(function () {
        init();

    })
    var pers = checkPermission();

    var example;
    function init(){
        var id = getUrlParam("id");
        example =
            $('#dt-table').DataTable({
                "searching": false,
                "processing": false,
                "serverSide" : true,
                "initComplete": function(settings, json) {
                    var lightBox =  new LightBox({
                        imgListParent: "imgDefault",
                        imgItemClass: "imgItem",
                        isShowPage: true
                    });
                    lightBox.init();
                },
                "language": {
                    "url": "/js/plugin/datatables/Chinese.lang"
                },
                "ajax": {
                    "url" : "/tTasks/listByBatchId",
                    "type":"post",
                    "data":function(d){
                        d.product_batches_id = id;
                    },
                    "error":function(xhr, textStatus, errorThrown){
                        var msg = xhr.responseText;
                    }
                },
                "dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
                "columns": [
                    { "data": "id", "defaultContent": ""},
                    { "data": "username", "defaultContent": ""},
                    { "data": "content", "defaultContent": ""},
                    { "data": "descContent", "defaultContent": ""},
                    { "data": "finishDate", "defaultContent": ""},
                    { "data": "state", "defaultContent": "",
                        "render" : function(data,type, row, meta) {
                            if(data == 1) {
                                return '下发成功';
                            } else if(data == 2) {
                                return '待审核'
                            } else if(data == 3) {
                                return '审核通过'
                            } else if(data == 4) {
                                return '异常'
                            } else if(data == null) {
                                return '未关联生产人员'
                            }
                        }},
                    { "data": "img1", "defaultContent": "",
                        "render" : function(data,type, row, meta) {
                            if(data == null) {
                                return '';
                            } else {
                                return '<div class="box imgDefault">' +
                                    '<img width="40px" height="40px" class="imgItem" alt="无图片加载" data-src="'+data+'" src="'+data+'"></div>'
                            }
                        }},
                    { "data": "img2", "defaultContent": "",
                        "render" : function(data,type, row, meta) {
                            if(data == null) {
                                return '';
                            } else {
                                return '<div class="box imgDefault">' +
                                    '<img width="40px" height="40px" class="imgItem" alt="无图片加载" data-src="'+data+'" src="'+data+'"></div>'
                            }
                        }},
                    { "data": "img3", "defaultContent": "",
                        "render" : function(data,type, row, meta) {
                            if(data == null) {
                                return '';
                            } else {
                                return '<div class="box imgDefault">' +
                                    '<img width="40px" height="40px" class="imgItem" alt="无图片加载" data-src="'+data+'" src="'+data+'"></div>'
                            }
                        }},
                    { "data": "area", "defaultContent": ""},
                    {
                        "data": "",
                        "defaultContent": "",
                        "orderable":false,
                        "render": function (data, type, row) {
                            var id = row['id'];
                            var state = row['state'];
                            if(state == 2) {
                                var auting = buttonAuting(id, "", pers);
                                return auting;
                            }
                        }
                    }
                ],
                "order": [[ 0, "desc" ],[1, "asc"]]
            } );
    }
    function auting(id){
        layer.confirm('审核通过？', {
            btn : [ '确定', '取消' ]
        }, function() {
            $.ajax({
                type : 'put',
                url : '/tTasks/',
                contentType: "application/json; charset=utf-8",
                data : JSON.stringify({
                    id:id,
                    state: 3
                }),
                success : function(data) {
                    example.ajax.reload();
                    layer.msg("审核成功");
                }
            });

            layer.close(1);
        });
    }
</script>
